package com.shujia.mr.dianxin1;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class DianXinMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        // ==> tl_hefei_shushan_503.txt <==
        // 47BE1E866CFC071DB19D5E1C056BE28AE24C16E7	117135031850040	83401	8340104	11	20180503224834	20180503224834	20180503
        // 8827F3196977C6F752680505FEC0C7D3A18D4DFC	\N	\N	\N	\N	\N	\N	\N
        String line = value.toString();
        if (!line.contains("hefei_shushan") && !line.contains("\\N")) {
            String[] infos = line.split("\t");
            String key1 = infos[0] + "-" + infos[3];
            long value1 = Long.parseLong(infos[4]);
            context.write(new Text(key1), new LongWritable(value1));
        }
    }
}
